package com.zl.annotation.demo2.service.impl;/**
 * @author suke
 * @create 2021-07-31 9:52
 */

import com.zl.annotation.demo2.dao.UserDao;
import com.zl.annotation.demo2.service.UserService;
import com.zl.annotation.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import javax.inject.Named;

/**
 * TODO
 * @ClassName: UserServiceImpl
 * @author: suke
 * @since: 2021/7/31 9:52
 */
@Service("userService")
public class UserServiceImpl implements UserService {
    @Value("UserService")  //通过set方式注入
    private String name;


    @Inject
    @Named("userDao") //根据id查找匹配的bean
    private UserDao userDao;


    @Override
    public void addUser(User user) {
        System.out.println(name);
        System.out.println(userDao);
        userDao.addUser(user);

    }

    @Override
    public User queryOne(int id) {
        return userDao.queryById(id);
    }
}
